\(\int \frac {(a+i a \tan (c+d x)) (A+B \tan (c+d x))}{\sqrt {\cot (c+d x)}} \, dx\) [506]

   Optimal result
   Rubi [A] (verified)
   Mathematica [A] (verified)
   Maple [B] (verified)
   Fricas [B] (verification not implemented)
   Sympy [F]
   Maxima [B] (verification not implemented)
   Giac [F]
   Mupad [F(-1)]

Optimal result

Integrand size = 34, antiderivative size = 80 \[ \int \frac {(a+i a \tan (c+d x)) (A+B \tan (c+d x))}{\sqrt {\cot (c+d x)}} \, dx=\frac {2 \sqrt [4]{-1} a (A-i B) \text {arctanh}\left ((-1)^{3/4} \sqrt {\cot (c+d x)}\right )}{d}+\frac {2 i a B}{3 d \cot ^{\frac {3}{2}}(c+d x)}+\frac {2 a (i A+B)}{d \sqrt {\cot (c+d x)}} \]

[Out]

2*(-1)^(1/4)*a*(A-I*B)*arctanh((-1)^(3/4)*cot(d*x+c)^(1/2))/d+2/3*I*a*B/d/cot(d*x+c)^(3/2)+2*a*(I*A+B)/d/cot(d
*x+c)^(1/2)

Rubi [A] (verified)

Time = 0.29 (sec) , antiderivative size = 80, normalized size of antiderivative = 1.00, number of steps used = 5, number of rules used = 5, \(\frac {\text {number of rules}}{\text {integrand size}}\) = 0.147, Rules used = {3662, 3672, 3610, 3614, 214} \[ \int \frac {(a+i a \tan (c+d x)) (A+B \tan (c+d x))}{\sqrt {\cot (c+d x)}} \, dx=\frac {2 \sqrt [4]{-1} a (A-i B) \text {arctanh}\left ((-1)^{3/4} \sqrt {\cot (c+d x)}\right )}{d}+\frac {2 a (B+i A)}{d \sqrt {\cot (c+d x)}}+\frac {2 i a B}{3 d \cot ^{\frac {3}{2}}(c+d x)} \]

[In]

Int[((a + I*a*Tan[c + d*x])*(A + B*Tan[c + d*x]))/Sqrt[Cot[c + d*x]],x]

[Out]

(2*(-1)^(1/4)*a*(A - I*B)*ArcTanh[(-1)^(3/4)*Sqrt[Cot[c + d*x]]])/d + (((2*I)/3)*a*B)/(d*Cot[c + d*x]^(3/2)) +
 (2*a*(I*A + B))/(d*Sqrt[Cot[c + d*x]])

Rule 214

Int[((a_) + (b_.)*(x_)^2)^(-1), x_Symbol] :> Simp[(Rt[-a/b, 2]/a)*ArcTanh[x/Rt[-a/b, 2]], x] /; FreeQ[{a, b},
x] && NegQ[a/b]

Rule 3610

Int[((a_.) + (b_.)*tan[(e_.) + (f_.)*(x_)])^(m_)*((c_.) + (d_.)*tan[(e_.) + (f_.)*(x_)]), x_Symbol] :> Simp[(b
*c - a*d)*((a + b*Tan[e + f*x])^(m + 1)/(f*(m + 1)*(a^2 + b^2))), x] + Dist[1/(a^2 + b^2), Int[(a + b*Tan[e +
f*x])^(m + 1)*Simp[a*c + b*d - (b*c - a*d)*Tan[e + f*x], x], x], x] /; FreeQ[{a, b, c, d, e, f}, x] && NeQ[b*c
 - a*d, 0] && NeQ[a^2 + b^2, 0] && LtQ[m, -1]

Rule 3614

Int[((c_) + (d_.)*tan[(e_.) + (f_.)*(x_)])/Sqrt[(b_.)*tan[(e_.) + (f_.)*(x_)]], x_Symbol] :> Dist[2*(c^2/f), S
ubst[Int[1/(b*c - d*x^2), x], x, Sqrt[b*Tan[e + f*x]]], x] /; FreeQ[{b, c, d, e, f}, x] && EqQ[c^2 + d^2, 0]

Rule 3662

Int[(cot[(e_.) + (f_.)*(x_)]*(g_.))^(p_)*((a_.) + (b_.)*tan[(e_.) + (f_.)*(x_)])^(m_.)*((c_) + (d_.)*tan[(e_.)
 + (f_.)*(x_)])^(n_.), x_Symbol] :> Dist[g^(m + n), Int[(g*Cot[e + f*x])^(p - m - n)*(b + a*Cot[e + f*x])^m*(d
 + c*Cot[e + f*x])^n, x], x] /; FreeQ[{a, b, c, d, e, f, g, p}, x] &&  !IntegerQ[p] && IntegerQ[m] && IntegerQ
[n]

Rule 3672

Int[((a_.) + (b_.)*tan[(e_.) + (f_.)*(x_)])^(m_)*((A_.) + (B_.)*tan[(e_.) + (f_.)*(x_)])*((c_.) + (d_.)*tan[(e
_.) + (f_.)*(x_)]), x_Symbol] :> Simp[(b*c - a*d)*(A*b - a*B)*((a + b*Tan[e + f*x])^(m + 1)/(b*f*(m + 1)*(a^2
+ b^2))), x] + Dist[1/(a^2 + b^2), Int[(a + b*Tan[e + f*x])^(m + 1)*Simp[a*A*c + b*B*c + A*b*d - a*B*d - (A*b*
c - a*B*c - a*A*d - b*B*d)*Tan[e + f*x], x], x], x] /; FreeQ[{a, b, c, d, e, f, A, B}, x] && NeQ[b*c - a*d, 0]
 && LtQ[m, -1] && NeQ[a^2 + b^2, 0]

Rubi steps \begin{align*} \text {integral}& = \int \frac {(i a+a \cot (c+d x)) (B+A \cot (c+d x))}{\cot ^{\frac {5}{2}}(c+d x)} \, dx \\ & = \frac {2 i a B}{3 d \cot ^{\frac {3}{2}}(c+d x)}+\int \frac {a (i A+B)+a (A-i B) \cot (c+d x)}{\cot ^{\frac {3}{2}}(c+d x)} \, dx \\ & = \frac {2 i a B}{3 d \cot ^{\frac {3}{2}}(c+d x)}+\frac {2 a (i A+B)}{d \sqrt {\cot (c+d x)}}+\int \frac {a (A-i B)-a (i A+B) \cot (c+d x)}{\sqrt {\cot (c+d x)}} \, dx \\ & = \frac {2 i a B}{3 d \cot ^{\frac {3}{2}}(c+d x)}+\frac {2 a (i A+B)}{d \sqrt {\cot (c+d x)}}+\frac {\left (2 a^2 (A-i B)^2\right ) \text {Subst}\left (\int \frac {1}{-a (A-i B)-a (i A+B) x^2} \, dx,x,\sqrt {\cot (c+d x)}\right )}{d} \\ & = \frac {2 \sqrt [4]{-1} a (A-i B) \text {arctanh}\left ((-1)^{3/4} \sqrt {\cot (c+d x)}\right )}{d}+\frac {2 i a B}{3 d \cot ^{\frac {3}{2}}(c+d x)}+\frac {2 a (i A+B)}{d \sqrt {\cot (c+d x)}} \\ \end{align*}

Mathematica [A] (verified)

Time = 1.04 (sec) , antiderivative size = 86, normalized size of antiderivative = 1.08 \[ \int \frac {(a+i a \tan (c+d x)) (A+B \tan (c+d x))}{\sqrt {\cot (c+d x)}} \, dx=\frac {2 i a \sqrt {\cot (c+d x)} \sqrt {\tan (c+d x)} \left (3 (A-i B) \left (\sqrt [4]{-1} \arctan \left ((-1)^{3/4} \sqrt {\tan (c+d x)}\right )+\sqrt {\tan (c+d x)}\right )+B \tan ^{\frac {3}{2}}(c+d x)\right )}{3 d} \]

[In]

Integrate[((a + I*a*Tan[c + d*x])*(A + B*Tan[c + d*x]))/Sqrt[Cot[c + d*x]],x]

[Out]

(((2*I)/3)*a*Sqrt[Cot[c + d*x]]*Sqrt[Tan[c + d*x]]*(3*(A - I*B)*((-1)^(1/4)*ArcTan[(-1)^(3/4)*Sqrt[Tan[c + d*x
]]] + Sqrt[Tan[c + d*x]]) + B*Tan[c + d*x]^(3/2)))/d

Maple [B] (verified)

Both result and optimal contain complex but leaf count of result is larger than twice the leaf count of optimal. 219 vs. \(2 (65 ) = 130\).

Time = 0.36 (sec) , antiderivative size = 220, normalized size of antiderivative = 2.75

method result size
derivativedivides \(-\frac {a \left (\frac {\left (-i B +A \right ) \sqrt {2}\, \left (\ln \left (\frac {1+\cot \left (d x +c \right )+\sqrt {2}\, \sqrt {\cot \left (d x +c \right )}}{1+\cot \left (d x +c \right )-\sqrt {2}\, \sqrt {\cot \left (d x +c \right )}}\right )+2 \arctan \left (1+\sqrt {2}\, \sqrt {\cot \left (d x +c \right )}\right )+2 \arctan \left (-1+\sqrt {2}\, \sqrt {\cot \left (d x +c \right )}\right )\right )}{4}+\frac {\left (-i A -B \right ) \sqrt {2}\, \left (\ln \left (\frac {1+\cot \left (d x +c \right )-\sqrt {2}\, \sqrt {\cot \left (d x +c \right )}}{1+\cot \left (d x +c \right )+\sqrt {2}\, \sqrt {\cot \left (d x +c \right )}}\right )+2 \arctan \left (1+\sqrt {2}\, \sqrt {\cot \left (d x +c \right )}\right )+2 \arctan \left (-1+\sqrt {2}\, \sqrt {\cot \left (d x +c \right )}\right )\right )}{4}-\frac {2 \left (i A +B \right )}{\sqrt {\cot \left (d x +c \right )}}-\frac {2 i B}{3 \cot \left (d x +c \right )^{\frac {3}{2}}}\right )}{d}\) \(220\)
default \(-\frac {a \left (\frac {\left (-i B +A \right ) \sqrt {2}\, \left (\ln \left (\frac {1+\cot \left (d x +c \right )+\sqrt {2}\, \sqrt {\cot \left (d x +c \right )}}{1+\cot \left (d x +c \right )-\sqrt {2}\, \sqrt {\cot \left (d x +c \right )}}\right )+2 \arctan \left (1+\sqrt {2}\, \sqrt {\cot \left (d x +c \right )}\right )+2 \arctan \left (-1+\sqrt {2}\, \sqrt {\cot \left (d x +c \right )}\right )\right )}{4}+\frac {\left (-i A -B \right ) \sqrt {2}\, \left (\ln \left (\frac {1+\cot \left (d x +c \right )-\sqrt {2}\, \sqrt {\cot \left (d x +c \right )}}{1+\cot \left (d x +c \right )+\sqrt {2}\, \sqrt {\cot \left (d x +c \right )}}\right )+2 \arctan \left (1+\sqrt {2}\, \sqrt {\cot \left (d x +c \right )}\right )+2 \arctan \left (-1+\sqrt {2}\, \sqrt {\cot \left (d x +c \right )}\right )\right )}{4}-\frac {2 \left (i A +B \right )}{\sqrt {\cot \left (d x +c \right )}}-\frac {2 i B}{3 \cot \left (d x +c \right )^{\frac {3}{2}}}\right )}{d}\) \(220\)

[In]

int((a+I*a*tan(d*x+c))*(A+B*tan(d*x+c))/cot(d*x+c)^(1/2),x,method=_RETURNVERBOSE)

[Out]

-a/d*(1/4*(A-I*B)*2^(1/2)*(ln((1+cot(d*x+c)+2^(1/2)*cot(d*x+c)^(1/2))/(1+cot(d*x+c)-2^(1/2)*cot(d*x+c)^(1/2)))
+2*arctan(1+2^(1/2)*cot(d*x+c)^(1/2))+2*arctan(-1+2^(1/2)*cot(d*x+c)^(1/2)))+1/4*(-I*A-B)*2^(1/2)*(ln((1+cot(d
*x+c)-2^(1/2)*cot(d*x+c)^(1/2))/(1+cot(d*x+c)+2^(1/2)*cot(d*x+c)^(1/2)))+2*arctan(1+2^(1/2)*cot(d*x+c)^(1/2))+
2*arctan(-1+2^(1/2)*cot(d*x+c)^(1/2)))-2*(I*A+B)/cot(d*x+c)^(1/2)-2/3*I*B/cot(d*x+c)^(3/2))

Fricas [B] (verification not implemented)

Both result and optimal contain complex but leaf count of result is larger than twice the leaf count of optimal. 429 vs. \(2 (62) = 124\).

Time = 0.25 (sec) , antiderivative size = 429, normalized size of antiderivative = 5.36 \[ \int \frac {(a+i a \tan (c+d x)) (A+B \tan (c+d x))}{\sqrt {\cot (c+d x)}} \, dx=-\frac {3 \, {\left (d e^{\left (4 i \, d x + 4 i \, c\right )} + 2 \, d e^{\left (2 i \, d x + 2 i \, c\right )} + d\right )} \sqrt {-\frac {{\left (-i \, A^{2} - 2 \, A B + i \, B^{2}\right )} a^{2}}{d^{2}}} \log \left (-\frac {2 \, {\left ({\left (A - i \, B\right )} a e^{\left (2 i \, d x + 2 i \, c\right )} - {\left (i \, d e^{\left (2 i \, d x + 2 i \, c\right )} - i \, d\right )} \sqrt {-\frac {{\left (-i \, A^{2} - 2 \, A B + i \, B^{2}\right )} a^{2}}{d^{2}}} \sqrt {\frac {i \, e^{\left (2 i \, d x + 2 i \, c\right )} + i}{e^{\left (2 i \, d x + 2 i \, c\right )} - 1}}\right )} e^{\left (-2 i \, d x - 2 i \, c\right )}}{{\left (i \, A + B\right )} a}\right ) - 3 \, {\left (d e^{\left (4 i \, d x + 4 i \, c\right )} + 2 \, d e^{\left (2 i \, d x + 2 i \, c\right )} + d\right )} \sqrt {-\frac {{\left (-i \, A^{2} - 2 \, A B + i \, B^{2}\right )} a^{2}}{d^{2}}} \log \left (-\frac {2 \, {\left ({\left (A - i \, B\right )} a e^{\left (2 i \, d x + 2 i \, c\right )} - {\left (-i \, d e^{\left (2 i \, d x + 2 i \, c\right )} + i \, d\right )} \sqrt {-\frac {{\left (-i \, A^{2} - 2 \, A B + i \, B^{2}\right )} a^{2}}{d^{2}}} \sqrt {\frac {i \, e^{\left (2 i \, d x + 2 i \, c\right )} + i}{e^{\left (2 i \, d x + 2 i \, c\right )} - 1}}\right )} e^{\left (-2 i \, d x - 2 i \, c\right )}}{{\left (i \, A + B\right )} a}\right ) - 4 \, {\left ({\left (3 \, A - 4 i \, B\right )} a e^{\left (4 i \, d x + 4 i \, c\right )} + 2 i \, B a e^{\left (2 i \, d x + 2 i \, c\right )} - {\left (3 \, A - 2 i \, B\right )} a\right )} \sqrt {\frac {i \, e^{\left (2 i \, d x + 2 i \, c\right )} + i}{e^{\left (2 i \, d x + 2 i \, c\right )} - 1}}}{6 \, {\left (d e^{\left (4 i \, d x + 4 i \, c\right )} + 2 \, d e^{\left (2 i \, d x + 2 i \, c\right )} + d\right )}} \]

[In]

integrate((a+I*a*tan(d*x+c))*(A+B*tan(d*x+c))/cot(d*x+c)^(1/2),x, algorithm="fricas")

[Out]

-1/6*(3*(d*e^(4*I*d*x + 4*I*c) + 2*d*e^(2*I*d*x + 2*I*c) + d)*sqrt(-(-I*A^2 - 2*A*B + I*B^2)*a^2/d^2)*log(-2*(
(A - I*B)*a*e^(2*I*d*x + 2*I*c) - (I*d*e^(2*I*d*x + 2*I*c) - I*d)*sqrt(-(-I*A^2 - 2*A*B + I*B^2)*a^2/d^2)*sqrt
((I*e^(2*I*d*x + 2*I*c) + I)/(e^(2*I*d*x + 2*I*c) - 1)))*e^(-2*I*d*x - 2*I*c)/((I*A + B)*a)) - 3*(d*e^(4*I*d*x
 + 4*I*c) + 2*d*e^(2*I*d*x + 2*I*c) + d)*sqrt(-(-I*A^2 - 2*A*B + I*B^2)*a^2/d^2)*log(-2*((A - I*B)*a*e^(2*I*d*
x + 2*I*c) - (-I*d*e^(2*I*d*x + 2*I*c) + I*d)*sqrt(-(-I*A^2 - 2*A*B + I*B^2)*a^2/d^2)*sqrt((I*e^(2*I*d*x + 2*I
*c) + I)/(e^(2*I*d*x + 2*I*c) - 1)))*e^(-2*I*d*x - 2*I*c)/((I*A + B)*a)) - 4*((3*A - 4*I*B)*a*e^(4*I*d*x + 4*I
*c) + 2*I*B*a*e^(2*I*d*x + 2*I*c) - (3*A - 2*I*B)*a)*sqrt((I*e^(2*I*d*x + 2*I*c) + I)/(e^(2*I*d*x + 2*I*c) - 1
)))/(d*e^(4*I*d*x + 4*I*c) + 2*d*e^(2*I*d*x + 2*I*c) + d)

Sympy [F]

\[ \int \frac {(a+i a \tan (c+d x)) (A+B \tan (c+d x))}{\sqrt {\cot (c+d x)}} \, dx=i a \left (\int \left (- \frac {i A}{\sqrt {\cot {\left (c + d x \right )}}}\right )\, dx + \int \frac {A \tan {\left (c + d x \right )}}{\sqrt {\cot {\left (c + d x \right )}}}\, dx + \int \frac {B \tan ^{2}{\left (c + d x \right )}}{\sqrt {\cot {\left (c + d x \right )}}}\, dx + \int \left (- \frac {i B \tan {\left (c + d x \right )}}{\sqrt {\cot {\left (c + d x \right )}}}\right )\, dx\right ) \]

[In]

integrate((a+I*a*tan(d*x+c))*(A+B*tan(d*x+c))/cot(d*x+c)**(1/2),x)

[Out]

I*a*(Integral(-I*A/sqrt(cot(c + d*x)), x) + Integral(A*tan(c + d*x)/sqrt(cot(c + d*x)), x) + Integral(B*tan(c
+ d*x)**2/sqrt(cot(c + d*x)), x) + Integral(-I*B*tan(c + d*x)/sqrt(cot(c + d*x)), x))

Maxima [B] (verification not implemented)

Both result and optimal contain complex but leaf count of result is larger than twice the leaf count of optimal. 177 vs. \(2 (62) = 124\).

Time = 0.29 (sec) , antiderivative size = 177, normalized size of antiderivative = 2.21 \[ \int \frac {(a+i a \tan (c+d x)) (A+B \tan (c+d x))}{\sqrt {\cot (c+d x)}} \, dx=\frac {8 \, {\left (i \, B a - \frac {3 \, {\left (-i \, A - B\right )} a}{\tan \left (d x + c\right )}\right )} \tan \left (d x + c\right )^{\frac {3}{2}} + 3 \, {\left (2 \, \sqrt {2} {\left (\left (i - 1\right ) \, A + \left (i + 1\right ) \, B\right )} \arctan \left (\frac {1}{2} \, \sqrt {2} {\left (\sqrt {2} + \frac {2}{\sqrt {\tan \left (d x + c\right )}}\right )}\right ) + 2 \, \sqrt {2} {\left (\left (i - 1\right ) \, A + \left (i + 1\right ) \, B\right )} \arctan \left (-\frac {1}{2} \, \sqrt {2} {\left (\sqrt {2} - \frac {2}{\sqrt {\tan \left (d x + c\right )}}\right )}\right ) + \sqrt {2} {\left (-\left (i + 1\right ) \, A + \left (i - 1\right ) \, B\right )} \log \left (\frac {\sqrt {2}}{\sqrt {\tan \left (d x + c\right )}} + \frac {1}{\tan \left (d x + c\right )} + 1\right ) - \sqrt {2} {\left (-\left (i + 1\right ) \, A + \left (i - 1\right ) \, B\right )} \log \left (-\frac {\sqrt {2}}{\sqrt {\tan \left (d x + c\right )}} + \frac {1}{\tan \left (d x + c\right )} + 1\right )\right )} a}{12 \, d} \]

[In]

integrate((a+I*a*tan(d*x+c))*(A+B*tan(d*x+c))/cot(d*x+c)^(1/2),x, algorithm="maxima")

[Out]

1/12*(8*(I*B*a - 3*(-I*A - B)*a/tan(d*x + c))*tan(d*x + c)^(3/2) + 3*(2*sqrt(2)*((I - 1)*A + (I + 1)*B)*arctan
(1/2*sqrt(2)*(sqrt(2) + 2/sqrt(tan(d*x + c)))) + 2*sqrt(2)*((I - 1)*A + (I + 1)*B)*arctan(-1/2*sqrt(2)*(sqrt(2
) - 2/sqrt(tan(d*x + c)))) + sqrt(2)*(-(I + 1)*A + (I - 1)*B)*log(sqrt(2)/sqrt(tan(d*x + c)) + 1/tan(d*x + c)
+ 1) - sqrt(2)*(-(I + 1)*A + (I - 1)*B)*log(-sqrt(2)/sqrt(tan(d*x + c)) + 1/tan(d*x + c) + 1))*a)/d

Giac [F]

\[ \int \frac {(a+i a \tan (c+d x)) (A+B \tan (c+d x))}{\sqrt {\cot (c+d x)}} \, dx=\int { \frac {{\left (B \tan \left (d x + c\right ) + A\right )} {\left (i \, a \tan \left (d x + c\right ) + a\right )}}{\sqrt {\cot \left (d x + c\right )}} \,d x } \]

[In]

integrate((a+I*a*tan(d*x+c))*(A+B*tan(d*x+c))/cot(d*x+c)^(1/2),x, algorithm="giac")

[Out]

integrate((B*tan(d*x + c) + A)*(I*a*tan(d*x + c) + a)/sqrt(cot(d*x + c)), x)

Mupad [F(-1)]

Timed out. \[ \int \frac {(a+i a \tan (c+d x)) (A+B \tan (c+d x))}{\sqrt {\cot (c+d x)}} \, dx=\int \frac {\left (A+B\,\mathrm {tan}\left (c+d\,x\right )\right )\,\left (a+a\,\mathrm {tan}\left (c+d\,x\right )\,1{}\mathrm {i}\right )}{\sqrt {\mathrm {cot}\left (c+d\,x\right )}} \,d x \]

[In]

int(((A + B*tan(c + d*x))*(a + a*tan(c + d*x)*1i))/cot(c + d*x)^(1/2),x)

[Out]

int(((A + B*tan(c + d*x))*(a + a*tan(c + d*x)*1i))/cot(c + d*x)^(1/2), x)